﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using WpfApplication1.Models;
using System.Windows.Media.Imaging;

namespace WpfApplication1.ViewModel
{
    public class FriendRequestViewModel : INotifyPropertyChanged
    {
        private FriendRequestModel friendrequest;

        public string Id
        {
            get { return friendrequest.Id; }
            set
            {
                friendrequest.Id = value;
                OnPropertyChanged("Id");
            }
        }

        public string Name
        {
            get { return friendrequest.Name; }
            set
            {
                friendrequest.Name = value;
                OnPropertyChanged("Name");
            }
        }

        public BitmapImage ProfilePicture
        {
            get
            {
                BitmapImage bm = new BitmapImage();
                bm.BeginInit();
                string urlPic = string.Format("https://graph.facebook.com/{0}/picture?type={1}", friendrequest.Id, "square");
                bm.UriSource = new Uri(urlPic);
                bm.EndInit();
                return bm;
            }
        }

        public FriendRequestViewModel(string id, string name)
        {
            friendrequest = new FriendRequestModel(id, name);
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
